import { useInfoStore } from "../store";
function checkPermission (el,auth){
    if(! Array.isArray(auth)){
        throw new Error("传递进来的值不是一个数组!");
    }
    const userStore = useInfoStore();
    // console.log('打印',userStore.ruleNames);
    const ruleNames = userStore.ruleNames;
    if(auth){ 
        let hasAuth = auth.findIndex(item => ruleNames.includes(item)) ===-1;
        if(hasAuth){
            el.parentNode && el.parentNode.removeChild(el);
        }
    }
}

export default{
    install(app){ 
        app.directive("permission",{
            mounted(el,binding){
                console.log('打印el',el);
                console.log('打印binding',binding.value);
                checkPermission(el,binding.value);
            }
        })
    }
    
}